From 986ded843feea53e2090f658b49d59d491ba637a Mon Sep 17 00:00:00 2001 From: robertlipe Date: Fri, 8 Feb 2013 07:06:48 +0000 Subject: [PATCH] Start moving geocache data to a class. It's complicated. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4285 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/defs.h | 23 ++++++++++++++++++++--- gpsbabel/waypt.cc | 6 +++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gpsbabel/defs.h b/gpsbabel/defs.h index 962765288..4c4abbea5 100644 --- a/gpsbabel/defs.h +++ b/gpsbabel/defs.h @@ -272,7 +272,24 @@ class utf_string{ char* utfstring; }; -typedef struct { +class geocache_data { + public: + geocache_data() : + id(0), + type(gt_unknown), + container(gc_unknown), + diff(0), + terr(0), + is_archived(status_unknown), + is_available(status_unknown), + is_memberonly(status_unknown), + has_customcoords(status_unknown), + placer(NULL), + placer_id(0), + hint(NULL), + favorite_points(0), + personal_note(NULL) + {} int id; /* The decimal cache number */ geocache_type type:5; geocache_container container:4; @@ -291,7 +308,7 @@ typedef struct { utf_string desc_long; int favorite_points; char* personal_note; -} geocache_data ; +}; typedef struct xml_tag { char* tagname; @@ -563,7 +580,7 @@ public: float power; /* watts, as measured by cyclists */ float temperature; /* Degrees celsius */ float odometer_distance; /* Meters? */ - const geocache_data* gc_data; + geocache_data* gc_data; format_specific_data* fs; session_t* session; /* pointer to a session struct */ void* extra_data; /* Extra data added by, say, a filter. */ diff --git a/gpsbabel/waypt.cc b/gpsbabel/waypt.cc index 7abe4c37a..9393f3f1b 100644 --- a/gpsbabel/waypt.cc +++ b/gpsbabel/waypt.cc @@ -29,7 +29,7 @@ queue waypt_head; static unsigned int waypt_ct; static short_handle mkshort_handle; -static geocache_data empty_gc_data = { 0 }; +static geocache_data empty_gc_data; static global_trait traits; const global_trait* get_traits(void) @@ -82,7 +82,7 @@ waypt_dupe(const waypoint *wpt) if (wpt->gc_data != &empty_gc_data) { geocache_data *gc_data = (geocache_data*) xmalloc(sizeof(*gc_data)); - tmp->gc_data = (const geocache_data *)gc_data; + tmp->gc_data = (geocache_data *)gc_data; memcpy(gc_data, wpt->gc_data, sizeof(*gc_data)); if (wpt->gc_data->desc_short.utfstring) { @@ -680,7 +680,7 @@ waypt_alloc_gc_data(waypoint *wpt) geocache_data *res = (geocache_data *)wpt->gc_data; if (res == &empty_gc_data) { res = (geocache_data*) xcalloc(1, sizeof(*res)); - wpt->gc_data = (const geocache_data *)res; + wpt->gc_data = (geocache_data *)res; } return res; -- 2.30.2